var modifyOrAddFlag;

$(document).ready(function(){
		$('#win').window('close');

		//导入
		$('#import_link').window({
			width:465,
			modal:true,
			minimizable:false,
			maximizable:false,
			collapsible:false
		});
		$('#import_link').window('close');  //关闭窗口

		$("#selFileBtn").click(function(e){
			e.preventDefault();
			//$("#file").click();
		});
		
		$('#importLinkFile').change(function() {
		    $("#fileName").val($('#importLinkFile').val());
		    //clearAutofillStyle();
		});
		
		//接口数据项
		$('#interfaceDataItem').window({
			width:505,
			height:480,
			modal:true,
			minimizable:false,
			maximizable:false,
			collapsible:false
		});
		$('#interfaceDataItem').window('close');  //关闭窗口

		$("#selFileBtn").click(function(e){
			e.preventDefault();
			//$("#file").click();
		});
		
		$(".import_con").delegate("#importLinkFile" ,"change", function() {
		    $("#fileName").val($('#importLinkFile').val());
		    //clearAutofillStyle();
		});
		
		$(".button_con a" ).removeClass("l-btn-plain");
		
		$('#comboxSearchfieldName').combobox({
			url: BASE_URL_FIELD_SEARCH + '/findAllOfCurrentUserCanManage' + '?v=' + Math.random(),
			valueField: 'id',
		    textField: 'name',
		    editable: false,
		    method:'get',
		    loadFilter: function(data){
		    	var allCheck = {'id':'','name':'全部'};
		    	data.content.unshift(allCheck);
		    	return data.content;
		    },
		    onSelect: function(record){
		    	comboxSearchSystemName.combobox({
                    disabled: false,
                    method:'get',
                    queryParams: {fieldId: record.id},
                    url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage' + '?v=' + Math.random(),
                    valueField: 'id',
                    textField: 'name',
        		    loadFilter: function(data){
        		    	var allCheck = {'id':'','name':'全部'};
        		    	data.content.unshift(allCheck);
        		    	return data.content;
        		    },
        		    onLoadSuccess:function(){
        		    	comboxSearchSystemName.combobox('setValue','');
        		    }
                }).load();
		    },
		    onLoadSuccess:function(){
		    	$('#comboxSearchfieldName').combobox('setValue','');
		    }
		});
		
		//所属系统下拉框
		var comboxSearchSystemName = $('#comboxSearchSystemName').combobox({
            disabled: true,
            valueField: 'id',
            textField: 'name',
            editable: false
        });
		
		//关联接口管理表格
		var randomNu = (new Date().getTime()) ^ Math.random();
		$("#datagrid").datagrid({
			url : BASE_URL_DBLINK_INTERFACE_SEARCH +'/findByExample?v=' + Math.random(),
			method:'get',
			autoRowHeight:true,
			nowrap:false,
			singleSelect:true,
			striped:true,
			pageSize:20,
			pageList:[10,20,50,100],
			columns:[[
						{field:'',width:10,checkbox:true},
						{field:'fieldName',title:'所属领域',width:100},
						{field:'fieldSystemName',title:'所属系统',width:100},
						{field:'name',title:'DBLINK关联接口名称',width:100},
						{field:'dblinkName',title:'DBLINK链接名称',width:100,formatter: function(value, rowData, rowIndex){
							return '<a href="javascript:void(0);" class="default_btn" onclick="linkDB(' + rowIndex + ');"  title="点击查看详情">' + value + '</a>';
							}
						},
						{field:'interfaceDataItem',title:'接口数据项',width:40,
							formatter: function(value,row,index){
							return '<a href="javascript:void(0);" style="width:60px;" onclick="interfaceDataItem(' + index + ')" class="default_btn">' + '查看' +'</a>';		
					} 
						
						}
					]],
			pagination:true,
			onSelect:function(rowIndex,rowData){
				$("#toolbar_edit").linkbutton('enable');
				$("#toolbar_delete").linkbutton('enable');
			},
			loadFilter:function(data){
				return {
					total: data.totalElements,
					rows: data.content
				};
			},
			//条件查询
			onBeforeLoad:function(param){
				param.page -= 1;
				param.size = param.rows;
				delete param.rows;
				
				param.sort = 'createTime,desc';

				
				var name = $('#txtSearchInterfaceName').val();
				if(name !=""){
					param.name = name;
				}
				
				var fieldName = $('#comboxSearchfieldName').combobox('getValue');
				if(fieldName !="全部"){
					param.fieldName = fieldName;
				}
				
				var fieldSystemName = $('#comboxSearchSystemName').combobox('getValue');
				if(fieldSystemName !="全部"){
					param.fieldSystemName = fieldSystemName;
				}
				
			}
		});
		
		$("#datagrid").datagrid('getPager').pagination({   
		    displayMsg:'当前显示从 [{from}] 到 [{to}] 共[{total}]条记录'
		}); 
		
		
		
		//维护区域所属领域下拉框 
		$('#comboxfieldName').combobox({
			url: BASE_URL_FIELD_SEARCH + '/findAllOfCurrentUserCanManage' + '?v=' + Math.random(),
			valueField: 'id',
			textField: 'name',
			method:'get',
			editable: false,
			loadFilter: function(data){
				return data.content;
			},
			onLoadSuccess:function(data){
				txtSystemName.combobox({
					disabled: false,
					method:'get',
					queryParams: {fieldId: data[0].id},
					url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage' + '?v=' + Math.random(),
					valueField: 'id',
					textField: 'name',
					loadFilter: function(data){
						return data.content;
					}
				}).load();
			},
			
			onSelect: function(record){
				txtSystemName.combobox({
					disabled: false,
					method:'get',
					queryParams: {fieldId: record.id},
					url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage' + '?v=' + Math.random(),
					valueField: 'id',
					textField: 'name',
					loadFilter: function(data){
						return data.content;
					}
				}).load();
			},
			onChange: function(newValue,oldValue){
				txtSystemName.combobox({
					disabled: false,
					method:'get',
					queryParams: {fieldId: newValue},
					url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage' + '?v=' + Math.random(),
					valueField: 'id',
					textField: 'name',
					loadFilter: function(data){
						return data.content;
					},
					onLoadSuccess:function(data){
					}
				}).load();
			}
			
		});
		
		//维护区域所属系统下拉框
		var txtSystemName = $('#comboxSystemName').combobox({
			disabled: true,
			valueField: 'id',
			textField: 'name',
			editable: false
			
		});
		
		//维护区域DBlink名
		$('#txtDBLINKLinkName').combobox({
			url: BASE_URL_DBLINK_MANAGE_SEARCH + '/findAll' + '?v=' + Math.random(),
			valueField: 'id',
			textField: 'name',
			method:'get',
			editable: false,
			loadFilter: function(data){
				return data;
			},
			onLoadSuccess:function(data){
				
			}
		});
		
		
		//弹框的数据类型选择
		$('#comboxDataType').combobox({
			url: BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCo?typeCode='+ DDTC_DATATYPE +'&v=' + Math.random(),
			valueField: 'valueCode',
			textField: 'valueName',
			editable:false,
			method:'get',
			loadFilter: function(data){
				return data;
			},
			onSelect:function(record)
			{
				
			},
			onLoadSuccess:function(data){
				
			}
			
		});
		
		//弹框的数据类型选择
		$('#reviseDataType').combobox({
			url: BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCo?typeCode='+ DDTC_DATATYPE +'&v=' + Math.random(),
			valueField: 'valueCode',
			textField: 'valueName',
			editable:false,
			method:'get',
			loadFilter: function(data){
				return data;
			},
			onSelect:function(record)
			{
				
			},
			onLoadSuccess:function(data){
				
			}
			
		});
		
		
		//动态添加接口数据项
		$(".confirm_title").click(function(e) {
			if($(".interfaceDataAdd").form("validate")){
	            var columnName = $("#txtcolumnName").val();
				var dataTypeDisplay = $("#comboxDataType").combobox('getText');
				var dataType = $("#comboxDataType").combobox('getValue');
				var dataTypeLength = $("#txtDataTypeLength").val();
				var columnCode = $("#txtColumnCode").val();
				if(columnName != '' && dataType !== '' &&  dataTypeLength !== '' && columnCode !== '')
				{
					var tableHtml = '<tr id="rev_index' + Math.floor(Math.random()*100000) + '"><td width="20%" class="txtColumnCode"><p class="txtP" title="' + columnCode + '">' + columnCode + '</p></td><td width="20%" class="txtDataType" data-val="' + dataType + '">' + dataTypeDisplay + '</td><td width="20%" class="txtDataTypeLength"><p class="txtP" title="' + dataTypeLength + '">' + dataTypeLength + '</p></td><td width="20%" class="txtcolumnName"><p class="txtP" title="' + columnName + '">' + columnName + '</p></td><td width="20%" class="operation_table"><a href="javascript:void(0);" class="change_title">更改</a><a href="javascript:void(0);" class="del_title">删除</a></td></tr>';
					$(".add").find("tr").eq(0).after(tableHtml);
					$("#txtcolumnName, #txtDataType, #txtDataTypeLength, #txtColumnCode").val('');
				}else
				{
					$.messager.alert('警告', '<p>请填写完整！</p>', 'warning');
				}
			}
			else
			{
				$(".interfaceDataAdd .validatebox-invalid").eq(0).focus();
			}
        });
		
		//删除接口数据项
		$("body").delegate(".del_title","click",function(){
			$(this).parents("tr").remove();
		});	
		
		
		//接口数据项修改
		$('#interface_change').window({
			width:555,
			height:140,
			modal:true,
			minimizable:false,
			maximizable:false,
			collapsible:false
		});
		$('#interface_change').window('close');  //关闭窗口	
		var rev_index;
		$("body").delegate(".change_title","click",function(e) {
			$("#revisecolumnName, #reviseDataType, #reviseDataTypeLength, #reviseColumnCode").val("");
			rev_index = $(this).parents("tr").attr("id");
			var columnName = $(this).parents("td").siblings(".txtcolumnName").text();
			var dataTypeLength = $(this).parents("td").siblings(".txtDataTypeLength").text();
			var columnCode = $(this).parents("td").siblings(".txtColumnCode").text();
			var html;
			$("#revisecolumnName").val(columnName);
			$("#reviseDataType").combobox('select',$(this).parents("td").siblings(".txtDataType").attr("data-val"));
			$("#reviseDataTypeLength").val(dataTypeLength)
			$("#reviseColumnCode").val(columnCode);
			$('#interface_change').window('open');	
			return false;
		});
		
		$("body").delegate(".confirm_title_revise","click",function(e) {
			$("#" + rev_index).children(".txtcolumnName").children(".txtP").html($("#revisecolumnName").val());
			$("#" + rev_index).children(".txtDataType").text($("#reviseDataType").combobox('getText'));
			$("#" + rev_index).children(".txtDataType").attr("data-val",$("#reviseDataType").combobox('getValue'));
			$("#" + rev_index).children(".txtDataTypeLength").text($("#reviseDataTypeLength").val());
			$("#" + rev_index).children(".txtColumnCode").children(".txtP").html($("#reviseColumnCode").val());
			$('#interface_change').window('close');			
		});

});
	//接口数据项显示
	function interfaceDataItem(index)
	{
		$('#datagrid').datagrid('selectRow',index);
		var row = $('#datagrid').datagrid('getSelected');
		$(".interfaceDataItem").html("");
		$.ajax({
					url: BASE_URL_DBLINK_INTERFACE_CRUD + '/' + row.id + '/dBlinkInterfaceColumnDefinitions'  + '?v=' + Math.random(),
					dataType:'json',
					type:'get',
					contentType:"application/json",
					success:function(data){
					 if(data._embedded !== undefined)	
					{
						var html = '';
						var dataArr = data._embedded.dBlinkInterfaceColumnDefinitions;
						for(var i = 0, len = dataArr.length; i < len; i++)
						{
							html += '<tr><td>' + (i+1) + '</td><td><p class="txtP" title="' + dataArr[i].columnCode + '">' + dataArr[i].columnCode + '</p></td><td data-val="' + dataArr[i].dataType + '">' + dataArr[i].dataTypeDisplay + '</td><td>' + dataArr[i].dataTypeLength + '</td><td>' + dataArr[i].columnName + '</td></tr>';
						}
						$(".interfaceDataItem").append(html);
						$('#interfaceDataItem').window('open');
					}else
					{
						$.messager.alert('警告', '<p>没有相关的接口数据项！</p>','warning');
					}
						
					},
					error:function(){
						$.messager.alert("错误","<p>服务异常，查询接口数据项失败，请重新登录或稍后再试！</p>","error");
					}
					
		});
		
	}
	
	//接口数据项数据转JSON
	var columnDefinitions;
	function interfaceData()
	{
		var table_con = $(".add tbody").children().clone();
		$(".interfaceData tbody").html('<tr><th width="20%">columnCode</th><th width="20%">dataType</th><th width="20%">dataTypeLength</th><th width="20%">columnName</th></tr>');
		$(".interfaceData tbody").append(table_con);
		$(".interfaceData tr:eq(1)").remove();
		for(var i = 1, len = $(".interfaceData tr").length; i < len; i++)
		{
			$(".interfaceData tr:eq(" + i + ") td:eq(1)").text($(".interfaceData tr:eq(" + i + ") td:eq(1)").attr("data-val"));
		}		
		$(".interfaceData tr td:last-child").remove();
		columnDefinitions = $('.interfaceData').tableToJSON(); 
	}
	
	//新增和保存
	function onSave(){
		
	 		var row = $('#datagrid').datagrid('getSelected');	
			interfaceData();
					
	 		var fieldSystemId = $("#comboxSystemName").combobox('getValue');
	 		var dblinkId = $("#txtDBLINKLinkName").combobox('getValue');
			var name = $("#txtDBLinkAssInterfaceName").val();
	 		var remark = $("#txtRemark").val();
	 		if(dblinkId==""){
	 			$.messager.alert("提示","<p>DBLINK链接名称不能为空！</p>","info");
	 			return;
	 		}

			$(".add input").attr("disabled","disabled");
	 		if($("#addForm").form("validate")){
				$("#instance_save").linkbutton("disable");
				$("#instance_save .l-btn-text").text("提交中...");
		 		if(!modifyOrAddFlag){
					var jsonData = JSON.stringify({
						id:row.id,
						name:name,
						fieldSystemId:fieldSystemId,
						dblinkId:dblinkId,
						remark:remark,
						columnDefinitions:columnDefinitions
					});
		 			$.ajax({
		 				url: BASE_URL_DBLINK_INTERFACE_CRUD + '/saveOrUpdate' + '?v=' + Math.random(),
		 				dataType:'json',
		 				type:'post',
		 				contentType:"application/json",
		 				data:jsonData,
		 				success:function(data){
		 					if(data.isCanSave===false){
		 						$.messager.alert("提示","<p>修改失败！数据库中已存在该DBLINK接口名！</p>","info");
		 					}else{
							$.messager.alert("提示","<p>修改成功！</p>","info");
							$('#win').window('close');
		 					$("#datagrid").datagrid("reload", BASE_URL_DBLINK_INTERFACE_SEARCH + '/findByExample?v=' + Math.random());
		 					}
							
							$("#instance_save").linkbutton("enable");
							$("#instance_save .l-btn-text").text("保存");
		 				},
		 				error:function(XMLHttpRequest, textStatus, errorThrown){
							$.messager.alert("错误","<p>服务异常，修改DBLINK关联接口失败，请重新登录或稍后再试！</p>","error");
							$("#instance_save").linkbutton("enable");
							$("#instance_save .l-btn-text").text("保存");
		 				}
		 				
		 			});
					$(".add input").removeAttr("disabled");
		 		}else{
					var jsonDataAdd = JSON.stringify({
						name:name,
						fieldSystemId:fieldSystemId,
						dblinkId:dblinkId,
						remark:remark,
						columnDefinitions:columnDefinitions
					});
		 			$.ajax({
		 				url: BASE_URL_DBLINK_INTERFACE_CRUD + '/saveOrUpdate' + '?v=' + Math.random(),
						dataType:'json',
		 				type:'post',
		 				contentType:"application/json",
		 				data:jsonDataAdd,
		 				success:function(result){
		 					if(result.isCanSave===false){
		 						$.messager.alert("提示","<p>新增失败！数据库中已存在该DBLINK接口名！</p>","info");
		 					}else{
							$.messager.alert("提示","<p>新增成功！</p>","info");
							$('#win').window('close');
		 					$("#datagrid").datagrid("reload", BASE_URL_DBLINK_INTERFACE_SEARCH + '/findByExample?v=' + Math.random());
		 					}
							$("#instance_save").linkbutton("enable");
							$("#instance_save .l-btn-text").text("保存");
		 				},
		 				error:function(){
							$.messager.alert("错误","<p>服务异常，新增DBLINK关联接口失败，请重新登录或稍后再试！</p>","error");
							$("#instance_save").linkbutton("enable");
							$("#instance_save .l-btn-text").text("保存");
		 				}
		 			});
					$(".add input").removeAttr("disabled");
		 		}
	 		}else
			{
				$(".add input").removeAttr("disabled");
			}
		}

	//进入新增界面	
	function add(){
		modifyOrAddFlag = true;
		//$('#addForm')[0].reset();
		$("#txtDBLinkAssInterfaceName, #txtRemark, #txtcolumnName, #txtDataTypeLength, #txtColumnCode").val('');
		setTimeout(function()
		{
			var data = $("#comboxfieldName").combobox("getData");
			$("#comboxfieldName").combobox('select',data[0].id);
			setTimeout(function()
			{
				var data2 = $("#comboxSystemName").combobox("getData");
				$("#comboxSystemName").combobox('select',data2[0].id);
			},300);
			
			var data3 = $("#txtDBLINKLinkName").combobox("getData");
			if(data3 != ""){
				$("#txtDBLINKLinkName").combobox('select',data3[0].id);
			}
			var data4 = $("#comboxDataType").combobox("getData");
			$("#comboxDataType").combobox('select',data4[0].valueCode);
			var data5 = $("#reviseDataType").combobox("getData");
			$("#reviseDataType").combobox('select',data5[0].valueCode);
		},200);	
		$(".add tr:not(:first)").remove();
		$('#win').window('open');
		
	}
	
	//进入修改界面
	function update(){
		var row = $('#datagrid').datagrid('getSelected');
		$("#txtDBLinkAssInterfaceName, #txtRemark, #txtcolumnName, #txtDataTypeLength, #txtColumnCode").val('');
		if(row == null){
			$.messager.alert("警告","<p>请选中要修改的记录!</p>","warning");
		}else{
			modifyOrAddFlag = false;
			$("#comboxfieldName").combobox('setValue',row.fieldId);
			$("#comboxSystemName").combobox('setValue',row.fieldSystemId);
			$("#txtDBLinkAssInterfaceName").val(row.name);
			$("#txtDBLINKLinkName").combobox('setValue',row.dblinkId);
			$("#txtRemark").val(row.remark);
			$(".add tr:not(:first)").remove();
			var data = $("#comboxDataType").combobox("getData");
			$("#comboxDataType").combobox('select',data[0].valueCode);
			$.ajax({
					url: BASE_URL_DBLINK_INTERFACE_CRUD + '/' + row.id + '/dBlinkInterfaceColumnDefinitions'  + '?v=' + Math.random(),
					dataType:'json',
					type:'get',
					contentType:"application/json",
					success:function(data){
					 if(data._embedded !== undefined)	
					{
						var html = '';
						var dataArr = data._embedded.dBlinkInterfaceColumnDefinitions;
						for(var i = 0, len = dataArr.length; i < len; i++)
						{
							html += '<tr id="rev_index' + Math.floor(Math.random()*100000) + '"><td width="20%" class="txtColumnCode"><p class="txtP" title="' + dataArr[i].columnCode + '">' + dataArr[i].columnCode + '</p></td><td width="20%" class="txtDataType" data-val="' + dataArr[i].dataType + '"><p class="txtP" title="' + dataArr[i].dataTypeDisplay + '">' + dataArr[i].dataTypeDisplay + '</p></td><td width="20%" class="txtDataTypeLength">' + dataArr[i].dataTypeLength + '</td><td width="20%" class="txtcolumnName"><p class="txtP" title="' + dataArr[i].columnName + '">' + dataArr[i].columnName + '</p></td><td width="20%" class="operation_table"><a href="javascript:void(0);" class="change_title">更改</a><a href="javascript:void(0);" class="del_title">删除</a></td></tr>';
						}
						$(".add").append(html);
					}
						
					},
					error:function(){

						$.messager.alert("错误","<p>服务异常，查询数据库链接信息失败，请重新登录或稍后再试！</p>","error");	
					}
					
			});
			$("#win").window('setTitle','DBLINK关联接口管理-修改');
			$('#win').window('open');
		}
	}
	
	
	//删除
	function del(){
		var row = $('#datagrid').datagrid('getSelected');
		if(row == null){
			$.messager.alert("警告","<p>请选中要删除的记录!</p>","warning");
		}else{
			if (row){
				$.messager.confirm('温馨提示','<p>你真的要删除么?</p>',function(result){
					if (result){
						$.ajax({
							url:BASE_URL_DBLINK_INTERFACE_CRUD + '/' + row.id  + '?v=' + Math.random(),
							dataType:'json',
							type:'delete',
							async:false,
							contentType:"application/json",
							timeout:30000,
							success:function(){
								$.messager.alert("提示","<p>删除成功！</p>","info");
								$("#datagrid").datagrid("reload", BASE_URL_DBLINK_INTERFACE_SEARCH + '/findByExample?v='  + Math.random());
							},
							error:function(xhr,s,err){
								$.messager.alert("错误","<p>服务异常，删除数据库链接失败，请重新登录或稍后再试！</p>","error");	
							}
						});
					}else
					{
						$("#datagrid").datagrid("reload", BASE_URL_DBLINK_INTERFACE_SEARCH + '/findByExample?v=' + Math.random());
					}
				});
			}
		}
	}
	//导入
	function import_link()
	{
		$('#import_link').window('open'); 
	}

	//导入
	function startImport() {
		if($("#importLinkFile").val() == "")
 		{
 			$.messager.alert("警告", "<p>请选择需要导入的.xls或.xlsx格式的文件!</p>","warning");
 			return;
 		}
 		var tempArr = $("#importLinkFile").val().split(".");
 		var selFileType = tempArr[tempArr.length - 1];
 		if(selFileType != "xls" && selFileType != "xlsx")
 		{
 			$.messager.alert("警告", "<p>选择的文件格式有误，请选择.xls或.xlsx格式的文件!</p>","warning");
 			return;
 		}
 		$("#buttons_inport .easyui-linkbutton").linkbutton("disable");
 		$("#buttons_inport .l-btn-text").text("正在导入...");
 		
		//$("#import_form").submit();
		$.ajaxFileUpload({
	        url: '/api/importData/dblinkInterface/fileUpload' + '?v=' + Math.random() + "&name=" + encodeURI($("#fileName").val()), 
	        type: 'post',
	        secureuri: false, //一般设置为false
	        fileElementId: 'importLinkFile', // 上传文件的id、name属性名
	        dataType: 'text', //返回值类型，一般设置为json、application/json
	        data: {name:""}, //传递参数到服务器
	        success: function(data, status){ 
	        	//var resultObj = eval("[" + data.activeElement.innerText + "]")[0];
	            $("#fileName").val($('#importLinkFile').val());
         		$("#buttons_inport .easyui-linkbutton").linkbutton("enable");
         		$("#buttons_inport .l-btn-text").text("确定导入");
         		
	        	var resultObj = JSON.parse(data.slice(data.indexOf(">") + 1,data.indexOf("</")));
	            if(resultObj.backValue === true)
	            {
	            	$('#import_link').window('close'); 
	        		$("#datagrid").datagrid("reload", BASE_URL_DBLINK_INTERFACE_SEARCH + '/findByExample?v=' + Math.random());
	            	$.messager.alert('提示',"<p>导入成功！</p>","info");
	            }
	            else if(resultObj.backValue === false)
	            {
	            	$.messager.alert('错误',"<p>导入失败!所选文件内容为空或存在异常！</p>","error");
	            }
	            else
	            {
	            	$.messager.alert('错误',"<p>导入失败！" + resultObj.backValue + "</p>", "error"); 
	            }
	        },
	        error: function(data, status, e){ 
         		$("#buttons_inport .easyui-linkbutton").linkbutton("enable");
         		$("#buttons_inport .l-btn-text").text("确定导入");
         		
	            $("#fileName").val($('#importLinkFile').val());
				$.messager.alert("错误","<p>服务异常，导入失败，请重新登录或稍后再试！</p>","error");	
	        }
	    });
	}
	
	function linkDB(rowIndex){
		$('#datagrid').datagrid('selectRow',rowIndex);
		var row = $('#datagrid').datagrid('getSelected');
		var title = "DBLINK管理";
		var param = row.dblinkName;
		var url = "/pages/LedgerManagement/DBlinkManage.html?name=" + param;
		var icon=$(this).attr("icon");
		window.parent.OpenTab(title,url,icon, true);
	}

	//查询
	function search(){
		$("#datagrid").datagrid("reload", BASE_URL_DBLINK_INTERFACE_SEARCH + '/findByExample?v=' + Math.random());

	}
	
	function rePage(){
		$('#win').window('close');
		$("#datagrid").datagrid("reload", BASE_URL_DBLINK_INTERFACE_SEARCH + '/findByExample?v=' + Math.random());
	}